<%--
  Created by IntelliJ IDEA.
  User: 22711
  Date: 2021/10/8
  Time: 18:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>门店查询</title>
    <link href="${pageContext.request.contextPath}/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/car_rental/select_car_two.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/dist/layui/css/layui.css" rel="stylesheet">
    <link href="http://r1nxp2i0y.hn-bkt.clouddn.com/images/ico.png" rel="icon" type="image/x-ico"/>

</head>
<style>
    .input-sec{
        width: 150px !important;
        height: 25px;
        border: 1px solid #ccc;
    }
</style>
<body>
<jsp:include page="../message.jsp"/>
<div class="header">
    <div class="head-top">
        <div class="w1180 top-linkbox">
            <div class="top-left">
                <c:if test="${empty loginCustomer}">
                    <span><a class="size-color" href="${pageContext.request.contextPath}/customer/login" target="_top">登录</a></span>
                    <span>|</span>
                    <span><a class="size-color" href="${pageContext.request.contextPath}/customer/register">免费注册</a></span>
                    <span>|</span>
                </c:if>
                <c:if test="${!empty loginCustomer}">
                    <c:if test="${empty loginCustomer.custName}">
                        <span>欢迎小橘用户登录</span>
                        <span><a class="size-color" href="${pageContext.request.contextPath}/customer/logout">退出</a></span>
                        <span><a href="${pageContext.request.contextPath}/user_center/${loginCustomer.custId}">我的小橘</a></span>
                    </c:if>
                    <c:if test="${!empty loginCustomer.custName}">
                        <span>欢迎 ${loginCustomer.custName} | </span>
                        <span><a class="size-color" href="${pageContext.request.contextPath}/customer/logout">退出</a></span>
                        <span><a href="${pageContext.request.contextPath}/user_center/${loginCustomer.custId}">我的小橘</a></span>
                    </c:if>
                </c:if>
            </div>
            <div class="top-right">
                <span><a href="">帮助中心</a></span>
                <span>|</span>
                <span><a href="">网址导航</a></span>
                <span>|</span>
                <span><a href="">English</a></span>
                <span>|</span>
                <span>400-888-6608</span>
                <span>|</span>
                <span><a href="">微信</a></span>
            </div>
        </div>
    </div>
    <div class="head-bottom">
        <div class="w1180">
            <a href="${pageContext.request.contextPath}" class="logo"></a>
            <div class="nav">
                <ul class="nav-wrap">
                    <li><a href="${pageContext.request.contextPath}">首页</a></li>
                    <li><a href="${pageContext.request.contextPath}/hotcar">热门车型</a></li>
                    <li><a href="${pageContext.request.contextPath}/car">车型查询</a></li>
                    <li><a href="${pageContext.request.contextPath}/store">营业网点</a></li>
                    <li><a href="${pageContext.request.contextPath}/coupon/toCoupon">精彩活动</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

<!--========================2. 内容 ==================================-->
<div class="main-wrap">
    <div class="main-box w1180">
        <div class="car-box">
            <div class="car-img">

                <img src="${serverResponse.data.carImagePath}" alt="${serverResponse.data.carName}"/>
            </div>
            <form action="" >
                <div class="car-info">
                    <div class="car-name">

                    </div>
                    <div class="car-des">
                        &nbsp;${serverResponse.data.carSeatNumber}座&nbsp;&nbsp;${serverResponse.data.carShiftType}
                        <a href="${pageContext.request.contextPath}/car/detail/${serverResponse.data.carId}" id="carDetail" class="view-car-para" data-cid="{'cartypeList':[191],'groupId':0}">车辆详情&gt;</a>
                    </div>
                    <p>
                <span>
                    <b>取车城市：</b>
                    <select class="input-sec">
                        <option>苏州</option>
                    </select>
                </span>
                        <span>
                    <b>还车城市：</b>
                            <select class="input-sec">
                                <option>苏州</option>
                            </select>
                </span>
                        <input autocomplete="off" data-val="true" data-val-number="字段 PickUpCityId 必须是一个数字。" data-val-required="PickUpCityId 字段是必需的。" id="PickUpCityId" name="PickUpCityId" readonly="readonly" type="hidden" value="77">
                        <input autocomplete="off" data-val="true" data-val-number="字段 ReturnCityId 必须是一个数字。" data-val-required="ReturnCityId 字段是必需的。" id="ReturnCityId" name="ReturnCityId" readonly="readonly" type="hidden" value="77">
                        <input autocomplete="off" id="PickUpStoreId" name="PickUpStoreId" readonly="readonly" type="hidden" value="886">
                        <input autocomplete="off" id="ReturnStoreId" name="ReturnStoreId" readonly="readonly" type="hidden" value="886">
                    </p>
                    <p>
                <span>
                    <b>取车时间：</b>
                    <input autocomplete="off" class="sel-date" data-val="true" id="test-limit-one" name="PickUpDate" readonly="readonly" type="text" value="2021-11-2">
                    <input autocomplete="off" class="sel-time" id="test-limit-three" readonly="readonly" type="text">
                </span>
                    <span>
                    <b>还车时间：</b>
                    <input autocomplete="off" class="sel-date" data-val="true" id="test-limit-two" name="ReturnDate" readonly="readonly" type="text" value="2021-11-3">
                    <input autocomplete="off" class="sel-time" id="test-limit-four" readonly="readonly" type="text" >
                </span>

                   <%-- <ul class="second">
                        <li>
                            <label class="key">
                                取车时间：
                            </label>
                            <div class="get-time">
                                <input class="car-date input-txt" id="test-limit-one" name="getCarDate" type="text">
                                <input class="car-time input-txt" id="test-limit-three" name="getCarTime" type="text">
                            </div>
                        </li>
                        <li>
                            <label class="key">
                                还车时间：
                            </label>
                            <div class="get-time">
                                <input class="car-date input-txt" id="test-limit-two" name="getCarDate" type="text">
                                <input class="car-time input-txt" id="test-limit-four" name="getCarTime" type="text">
                            </div>
                        </li>
                    </ul>--%>

                        <input type="submit" value="查询" class="submit">
                        <input id="hdnReturnHour" name="ReturnHour" type="hidden" value="9">
                        <input id="hdnPickupHour" name="PickUpHour" type="hidden" value="9">
                        <input id="hdnReturnMinute" name="ReturnMinute" type="hidden" value="0">
                        <input id="hdnPickUpMinute" name="PickUpMinute" type="hidden" value="0">
                    </p>
                </div>
            </form>    <p class="company-prompt" id="companyPrompt"></p>
            <a class="sel-car" href="${pageContext.request.contextPath}/hotcar">调整车型</a>
        </div>


        <div class="search-box">
            <a title="地图模式查看" class="view-map isread" id="J_ShowMap" href="${pageContext.request.contextPath}/store">地图模式查看</a>
<%--            <span>查找附近门店：</span>--%>
<%--            <input type="text" id="J_Address" value="请输入您的位置！">--%>
<%--            <a class="confirm" href="javascript:;" id="J_SearchSubmit" title="确定">确定</a>--%>

        </div>

        <div class="store-box" id="J_StoreBoxe"><div class="area-box " id="J_AreaBox">
            <div>
                <a href="javascript:void(0)" class="on">全部</a>
                <a href="javascript:void(0)" class="area1">姑苏区</a>
                <a href="javascript:void(0)" class="area2">工业园区</a>
                <a href="javascript:void(0)" class="area3">吴中区</a>
                <a href="javascript:void(0)" class="area4">相城区</a>
            </div>
        </div>

            <!---=================================门店列表======================-->
            <div class="show-store-list"></div>
<%--            <div class="store-list clear_float">--%>
<%--                <div class="store-info" sd="浦东新区" st="0">--%>
<%--                    <p>--%>
<%--                        金桥店--%>
<%--                    </p>--%>
<%--                    <span>上海市浦东新区张杨北路529号</span>--%>
<%--                </div>--%>

<%--                <div class="store-price">--%>

<%--                    <em>¥</em>128<i>/日均</i>--%>
<%--                </div>--%>
<%--                <div class="store-btn">--%>
<%--                    <i style="display: none">carId</i>--%>
<%--                    <a href="javascript:void(0)"><span>预定</span></a>--%>
<%--                </div>--%>
<%--                <span class="typebtn btntop1">--%>
<%--        <a href="/Order/BrandStep2/Booking?PriceType=1&amp;storeId=391&amp;CarType=191" class="type-four  btn-book">--%>
<%--            <span>--%>
<%--                门店现付<br>--%>
<%--            </span><i class="symbol">¥</i>--%>
<%--            <em class="total-price">128</em>--%>
<%--        </a>--%>
<%--            </span>--%>
<%--            </div>--%>

        </div>
    </div>
</div>


<!--底部-->
<div class="footer">
    <div class="footer-box clear_float">
        <div class="footer-left">
            <p>
                <a href="" >关于小橘</a>
                |
                <a href="" >移动客户端</a>
                |
                <a href="" >帮助中心</a>
                |
                <a href="" >建议专区</a>
                |
                <a href="" >联系我们</a>
                |
                <a href="" >友情链接</a>
                | &nbsp;投诉通道：400-821-1608 &nbsp;
            </p>
            <p>
                Copyright © 2007 - 2021 上海小橘信息技术服务有限公司
                <a href="" >ICP证：沪B2-20140130</a>
            </p>
        </div>
        <div class="footer-right">
            <a href="">
                <img src="http://r1nxp2i0y.hn-bkt.clouddn.com/images/footer_right_first.png">
            </a>
            <a href="">
                <img src="http://r1nxp2i0y.hn-bkt.clouddn.com/images/footer_right_second.png">
            </a>
            <a href="">
                <img src="http://r1nxp2i0y.hn-bkt.clouddn.com/images/footer_right_third.png">
            </a>
            <a href="">
                <img src="http://r1nxp2i0y.hn-bkt.clouddn.com/images/footer_right_forth.png">
            </a>
        </div>
    </div>
    <script src="${pageContext.request.contextPath}/dist/layui/layui.js"></script>
    <script src="${pageContext.request.contextPath}/js/car_rental/select_car_two.js"></script>
</div>

<script>
    var carId = ${serverResponse.data.carId};
    url = "${pageContext.request.contextPath}/car/"+carId+"/store/"+"-1";

    $.get(url,null,function (result) {
        console.log("result",result);
        console.log("result",JSON.stringify(result));
        if (result.code==200){
            var resultArray=result.data;
            for (var i=0;i<resultArray.length;i++){
                var storeName=resultArray[i].storeName;
                var carPrice = "${serverResponse.data.carDailyPrice}";
                var storeId = resultArray[i].storeId;
                var storeProvince = resultArray[i].storeProvince;
                var storeCity = resultArray[i].storeCity;
                var storeArea = resultArray[i].storeArea;
                var storeDetailAddress = resultArray[i].storeDetailAddress;
                var storeAddress = storeProvince + storeCity + storeArea + storeDetailAddress;
                var storeEle='<div class="store-list clear_float">\n' +
                    '                <div class="store-info" sd="浦东新区" st="0">\n' +
                    '                    <p>\n' +
                    '                        '+storeName+'\n' +
                    '                    </p>\n' +
                    '                    <span>'+storeDetailAddress+'</span>\n' +
                    '                </div>\n' +
                    '\n' +
                    '                <div class="store-price">\n' +
                    '\n' +
                    '                    <em>¥</em>'+carPrice+'<i>/日均</i>\n' +
                    '                </div>\n' +
                    '                <div class="store-btn">\n' +
                    '                    <span style="display: none">'+storeId+'</span>\n' +
                    '                    <a href="javascript:void(0)"><span>预订</span></a>\n' +
                    '                </div>\n' +
                    '                <span class="typebtn btntop1">\n' +
                    '        <a href="/Order/BrandStep2/Booking?PriceType=1&amp;storeId=391&amp;CarType=191" class="type-four  btn-book">\n' +
                    '            <span>\n' +
                    '                门店现付<br>\n' +
                    '            </span><i class="symbol">¥</i>\n' +
                    '            <em class="total-price">128</em>\n' +
                    '        </a>\n' +
                    '            </span>\n' +
                    '            </div>';
                $(".show-store-list").append(storeEle);
            }
        }
    },"json");

    $("#J_AreaBox").click(function (event) {
        var target = event.target;
        var text = target.parentElement.children[0].text;
        var url = "";
        if(text == "全部"){
            var carId = "${serverResponse.data.carId}";
            var storeArea = target.text;
            console.log(carId);
            console.log(storeArea);
            if(storeArea == "全部")
                storeArea = -1;
            url = "${pageContext.request.contextPath}/car/"+carId+"/store/"+storeArea;
            $(".show-store-list").html("");
       $.get(url,null,function (result) {
            console.log("result",result);
            console.log("result",JSON.stringify(result));
            if (result.code==200){
                var resultArray=result.data;
                for (var i=0;i<resultArray.length;i++){
                    var storeName=resultArray[i].storeName;
                    var storeId = resultArray[i].storeId;
                    var carPrice = "${serverResponse.data.carDailyPrice}";
                    var storeProvince = resultArray[i].storeProvince;
                    var storeCity = resultArray[i].storeCity;
                    var storeArea = resultArray[i].storeArea;
                    var storeDetailAddress = resultArray[i].storeDetailAddress;
                    var storeAddress = storeProvince + storeCity + storeArea + storeDetailAddress;
                    var storeEle='<div class="store-list clear_float">\n' +
                        '                <div class="store-info" sd="浦东新区" st="0">\n' +
                        '                    <p>\n' +
                        '                        '+storeName+'\n' +
                        '                    </p>\n' +
                        '                    <span>'+storeDetailAddress+'</span>\n' +
                        '                </div>\n' +
                        '\n' +
                        '                <div class="store-price">\n' +
                        '\n' +
                        '                    <em>¥</em>'+carPrice+'<i>/日均</i>\n' +
                        '                </div>\n' +
                        '                <div class="store-btn">\n' +
                        '                    <span style="display: none">' + storeId + '</span>\n' +
                        '                    <a href="javascript:void(0)"><span>预定</span></a>\n' +
                        '                </div>\n' +
                        '                <span class="typebtn btntop1">\n' +
                        '        <a href="/Order/BrandStep2/Booking?PriceType=1&amp;storeId=391&amp;CarType=191" class="type-four  btn-book">\n' +
                        '            <span>\n' +
                        '                门店现付<br>\n' +
                        '            </span><i class="symbol">¥</i>\n' +
                        '            <em class="total-price">128</em>\n' +
                        '        </a>\n' +
                        '            </span>\n' +
                        '            </div>';
                    $(".show-store-list").append(storeEle);
                }
            }
       },"json")
        }
    })
</script>
    <script>
        $(".show-store-list").click(function (event){
            var eventText = event.target.innerText;
            var custId = "${loginCustomer.custId}";
            if(eventText == "预订"){
                if(custId != ""){
                    var carId=${serverResponse.data.carId};
                    var storeId=event.target.parentElement.previousElementSibling.innerText;
                    console.log("storeId是:"+storeId);
                    var borrowStoreId = storeId;
                    var returnStoreId = storeId;
                    var getCarDate = $("#test-limit-one").val();
                    var getCarTime = $("#test-limit-three").val();
                    var returnCarDate = $("#test-limit-two").val();
                    var returnCarTime = $("#test-limit-four").val();
                    console.log("carId:"+carId);

                    getCarTime = getCarDate+" " + getCarTime;
                    console.log("getCarTime:"+getCarTime);

                    returnCarTime = returnCarDate + " " +returnCarTime;
                    var returnCarTime2 = new Date(returnCarTime);

                    returnCarTime2 = returnCarTime2.setHours(returnCarTime2.getHours()-9);

                    console.log("returnCarTime: " + returnCarTime);
                    console.log("getCarTime:" + new Date(getCarTime));
                    if(new Date(getCarTime) <= new Date()){
                        alert("取车时间不能小于当前时间~");
                    }else if(new Date(getCarTime) >= returnCarTime2){
                        alert("取车时间与还车时间间隔不能小于九个小时~");
                    }else{
                        var url = '${pageContext.request.contextPath}/myOrder_second?custId=' + custId + '&carId=' + carId +'&borrowStoreId=' + borrowStoreId + '&returnStoreId=' + returnStoreId + '&getCarTime=' + getCarTime + '&returnCarTime='+returnCarTime+'';
                        window.location.href = url;
                    }
                }else {
                    window.location.href="${pageContext.request.contextPath}/customer/login";
                }
            }
        });

    </script>
</body>
</html>